#include<iostream>
using namespace std;

int conseq(int n){
    if(n<3)
        return 0;
    int num=0,small=1,big=2,mid=(n+1)/2,sum=small+big;
    while(small < mid){
        if(sum==n)
            num++;
        while(sum>n){
            sum -= small;
            small++;
            if(sum==n)
                num++;
        }
        big++;
        sum+=big;
    }
    return num;
}

int conseq2(int n){
    int i,j,k,num;
     num = 0;
    for(i=1;i<=(n/2);i++){
        k = i;
        for(j=i+1;j<n;j++){
            k += j;
            if(k==n){
                num++;
                printf("%d %d\n",i,j);
                break;
            }else if(k>n)
                break;
        }
    }
    return num;
}

int main(){
    int n,i,j,k,num;
    while(cin>>n,n>0){
        printf("%d\n",conseq(n));
    }
    return 0;
}
